#coding=utf-8
import socket
import sys
socket.setdefaulttimeout(0.01)
def port_scan(taghost,tagport):
    """ 这是一个例子程序 """
    try:
        s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        s.connect((taghost,int(tagport)))
        print "开放端口",tagport
        s.close()
    except:
        print "%s %s 这个端口没开放"% (taghost,tagport)
    finally:
        s.close()

if __name__ == '__main__':
    if len(sys.argv) !=3:
        print "example:python xxx.py ip port"
    else:
        port_scan(sys.argv[1],sys.argv[2])
